home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-13 / ncu_edit.zip / ED_2.ASM < prev    next >
Assembly Source File  |  1992-12-06  |  33KB  |  1,226 lines

  1. ;+--------------+
  2. ;| Edit Part II |
  3. ;+--------------+
  4. public    display_,ins_line,del_line,put_buff,get_buff,find_ptr
  5. public    load_act,newing,save_act,print_act,help_win,write_act,chg_drive
  6. public    p_ptr,q_ptr,r_ptr,free_top,free_ptr,line_buf,block_top,block_end
  7. extrn     info_win:near
  8. extrn     refresh_:near
  9. extrn     here_dir:near
  10. extrn     new_act:near
  11. extrn     read_line:near
  12. extrn     show_name:near
  13. extrn     new_end:word
  14. extrn     top_:byte
  15. extrn     bottom_:byte
  16. extrn     total_l:word
  17. extrn     monitor:word
  18. extrn     y_table:word
  19. extrn     cursor_y:word
  20. extrn     file_top:word
  21. extrn     file_ptr:word
  22. extrn     file_name:byte
  23. extrn     handle_:word
  24. extrn     psp_start:word
  25. extrn     this_dir:byte
  26.  
  27. buf_max   equ      2048
  28.  
  29. NEW_      MACRO                         ;AX register save the Segment
  30.           LOCAL    over_z,exist_
  31.           push     es
  32.           push     bx
  33.           cmp      free_top,0
  34.           jne      exist_
  35.  
  36.           add      new_end,2
  37.           mov      ax,new_end
  38.           jmp      over_z
  39.  
  40.   exist_: mov      ax,free_top
  41.           mov      es,ax
  42.           mov      bx,es:[0]
  43.           mov      free_top,bx
  44.   over_z: pop      bx
  45.           pop      es
  46.           ENDM
  47.  
  48. FREE_     MACRO    _ptr
  49.           LOCAL    n_empt,free_z
  50.           push     es
  51.           pushf
  52.           mov      ax,_ptr
  53.           cmp      free_top,0
  54.           jne      n_empt
  55.           mov      free_top,ax
  56.           jmp      free_z
  57.  
  58.   n_empt: mov      es,free_ptr
  59.           mov      es:[0],ax
  60.   free_z: mov      free_ptr,ax
  61.           mov      es,ax
  62.           mov      word ptr es:[0],0
  63.           popf
  64.           pop      es
  65.           ENDM
  66.  
  67. CURSOR_1  MACRO
  68.           push     cx
  69.           mov      ch,0bh
  70.           mov      cl,0ch
  71.           mov      ah,1
  72.           int      10h
  73.           pop      cx
  74.           ENDM
  75.  
  76. CURSOR_0  MACRO
  77.           push     cx
  78.           mov      ch,1ch
  79.           mov      cl,1bh
  80.           mov      ah,1
  81.           int      10h
  82.           pop      cx
  83.           ENDM
  84.  
  85. data      segment  public
  86. p_ptr     dw ?                          ;Here Pointer
  87. q_ptr     dw ?
  88. r_ptr     dw ?                          ;Front Pointer
  89. p_lin     dw ?                          ;Line Here
  90. q_lin     dw ?                          ;
  91. free_top  dw ?
  92. free_ptr  dw ?
  93. local_y   dw ?
  94. block_top dw ?
  95. block_end dw ?
  96. attr_line db ?
  97. eol_flag  db ?
  98. dir_      db '*.*',0
  99. total_f   dw ?
  100. total_d   dw ?
  101. file_y    dw ?
  102. line_buf  db 258 dup(0)
  103. msg_      db '██████▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒░░░░░░░░░░░░ ERR'
  104.           db 'OR! ░░░░░░░░░░░░▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓██████'
  105. load_fun  db 30
  106.           db '┌─Load File──────────────────╖'
  107.           db '│                            ║'
  108.           db '├────────────────────────────╢'
  109.           db '│   │                    │   ║'
  110.           db '╘════════════════════════════╝'
  111. write_fun db 33
  112.           db '┌────────── Write to ───────────╖'
  113.           db '│                               ║'
  114.           db '╘═══════════════════════════════╝'
  115. wrt_file  db 30 dup(0)
  116. drive_fun db 37
  117.           db '┌───────────────────────────────────╖'
  118.           db '│ Change Disk-Drive From [ ] to [ ] ║'
  119.           db '╘═══════════════════════════════════╝'
  120. win_help  db 59,15
  121.           db '┌────────────────────────── Help ─────────────────────────╖'
  122.           db '├────────────────────────────────┬────────────────────────╢'
  123.           db '│        ■ Define Key ■          │    ■ Introduction ■    ║'
  124.           db '├────────────────────────────────┼────────────────────────╢'
  125.           db '│ Shift-Ctrl-N = Insert 1 line   │ Author: Chen Jean-Yean ║'
  126.           db '│ Shift-Ctrl-Y = Delete 1 line   │ Number: 790854         ║'
  127.           db '│ ────────────────────────────── │ Dept. : MIS            ║'
  128.           db '│ Shift-Ctrl-B = Set Block Begin │ Class : 2A             ║'
  129.           db '│ Shift-Ctrl-K = Set Block End   │                        ║'
  130.           db '│ Shift-Ctrl-M = Move Block      │ ██▄  ██ ▄█▀▀▀▀ ██  ▐█▌ ║'
  131.           db '│ Shift-Ctrl-D = Delete Block    │ ██ ▀▄██ ██     ██  ▐█▌ ║'
  132.           db '│ Shift-Ctrl-O = Copy Block      │ ▀▀   ▀▀  ▀▀▀▀▀  ▀▀▀▀▀  ║'
  133.           db '│ Shift-Ctrl-P = Print Block     │ National Central Univ. ║'
  134.           db '│ Shift-Ctrl-H = Hide Block      │                        ║'
  135.           db '╘════════════════════════════════╧════════════════════════╝'
  136. buffer_   db 2048 dup(0)
  137. data      ends
  138.  
  139. code      segment  public
  140.           assume   cs:code,ds:data
  141.  
  142. display_  proc     near                 ;Stack Put Start_line
  143.           push     bp                   ;Stack Put Start_Col
  144.           mov      bp,sp
  145.           push     ax
  146.           push     bx
  147.           push     cx
  148.           push     dx
  149.  
  150.           mov      local_y,0
  151.           mov      bx,[bp+6]
  152.           mov      dx,[bp+4]
  153.           push     bx
  154.           call     find_ptr              ;Result put in p_ptr
  155.           mov      cx,total_l
  156.           sub      cx,bx
  157.           add      cx,2
  158.           cmp      cx,21
  159.           jb       less
  160.  
  161.           mov      cx,21                ;Screen Full
  162.   mor_21: inc      local_y
  163.           call     disp_line
  164.           inc      bx
  165.           push     bx
  166.           call     find_ptr
  167.           loop     mor_21
  168.           jmp      dis_f
  169.  
  170.   less:   push     cx
  171.   low_21: inc      local_y
  172.           call     disp_line
  173.           inc      bx
  174.           push     bx
  175.           call     find_ptr
  176.           loop     low_21
  177.  
  178.           pop      cx
  179.           mov      ch,cl
  180.           mov      al,0                 ;Clear Screen
  181.           add      ch,2
  182.           mov      cl,0
  183.           mov      dh,22
  184.           mov      dl,79
  185.           mov      bh,07
  186.           mov      ah,6
  187.           int      10h
  188.   dis_f:
  189.           pop      ax
  190.           pop      dx
  191.           pop      cx
  192.           pop      bx
  193.           pop      bp
  194.           ret      4
  195. display_  endp
  196.  
  197. find_ptr  proc     near                 ;Stack Put Which No. be Finded
  198.           push     bp
  199.           mov      bp,sp
  200.           push     ax
  201.           push     cx
  202.           push     es
  203.           pushf
  204.           mov      p_ptr,seg top_
  205.           mov      ax,p_ptr
  206.           mov      r_ptr,ax
  207.           mov      cx,[bp+4]
  208.           cmp      cx,0
  209.           je       fnd_ok
  210.   find_n: mov      es,p_ptr
  211.           mov      r_ptr,es             ;r_ptr:=p_ptr
  212.           mov      ax,es:[0]            ;p_ptr:=p_ptr^.next
  213.           mov      p_ptr,ax
  214.           loop     find_n
  215.  
  216.   fnd_ok: popf
  217.           pop      es
  218.           pop      cx
  219.           pop      ax
  220.           pop      bp
  221.           ret      2
  222. find_ptr  endp
  223.  
  224. disp_line proc     near                 ;DX register Put Start_Col
  225.           push     ax
  226.           push     bx
  227.           push     cx
  228.           push     di
  229.           push     si
  230.           push     es
  231.           pushf
  232.  
  233.           mov      attr_line,07h
  234.           cmp      bx,block_top
  235.           jb       no_rev
  236.           cmp      bx,block_end
  237.           jae      no_rev
  238.           mov      attr_line,70h
  239.  
  240.   no_rev: mov      ah,attr_line
  241.           mov      bx,local_y
  242.           inc      bx
  243.           shl      bx,1
  244.           call     put_buff
  245.           mov      es,monitor
  246.           xor      cx,cx
  247.           mov      cl,line_buf
  248.           cmp      cx,dx
  249.           jb       over_d
  250.           sub      cx,dx
  251.           inc      cx
  252.           push     cx
  253.           cmp      cx,80
  254.           jbe      legal
  255.           mov      cx,80
  256.   legal:  mov      di,dx
  257.           mov      si,y_table[bx]
  258.   rep_c:  mov      al,line_buf[di]
  259.           mov      es:[si],al
  260.           mov      es:[si+1],ah
  261.           add      si,2
  262.           inc      di
  263.           loop     rep_c
  264.           pop      cx
  265.           cmp      cx,80
  266.           jae      l_e
  267.           neg      cx
  268.           add      cx,80
  269.   _80:    mov      byte ptr es:[si],' '
  270.           mov      es:[si+1],ah
  271.           add      si,2
  272.           loop     _80
  273.           jmp      l_e
  274.  
  275.   over_d: mov      cx,80
  276.           mov      di,y_table[bx]
  277.   n80:    mov      byte ptr es:[di],' '
  278.           mov      es:[di+1],ah
  279.           add      di,2
  280.           loop     n80
  281.  
  282.   l_e:    popf
  283.           pop      es
  284.           pop      si
  285.           pop      di
  286.           pop      cx
  287.           pop      bx
  288.           pop      ax
  289.           ret
  290. disp_line endp
  291.  
  292. put_buff  proc     near
  293.           push     ax
  294.           push     cx
  295.           push     es
  296.           push     di
  297.           push     si
  298.           mov      es,word ptr p_ptr
  299.           mov      cx,28
  300.           mov      di,2
  301.           mov      si,0
  302.  
  303.   b_1:    mov      al,es:[di]           ;Part 1
  304.           mov      line_buf[si],al
  305.           inc      si
  306.           inc      di
  307.           loop     b_1
  308.           cmp      word ptr es:[30],0
  309.           je       out_
  310.  
  311.   mor_b:  mov      ax,es:[30]
  312.           mov      es,ax
  313.           mov      cx,30
  314.           mov      di,0
  315.   b_n:    mov      al,es:[di]
  316.           mov      byte ptr line_buf[si],al
  317.           inc      si
  318.           inc      di
  319.           loop     b_n
  320.           cmp      word ptr es:[30],0
  321.           jne      mor_b
  322.  
  323.   out_:   pop      si
  324.           pop      di
  325.           pop      es
  326.           pop      cx
  327.           pop      ax
  328.           ret
  329. put_buff  endp
  330.  
  331. get_buff  proc     near
  332.           push     es
  333.           push     di
  334.           push     si
  335.           push     ax
  336.           push     bx
  337.           push     cx
  338.           pushf
  339.  
  340.           mov      es,p_ptr
  341.           mov      p_lin,es
  342.           mov      q_lin,es
  343.           xor      ax,ax
  344.           mov      al,es:[2]            ;No. Chars in Linked List
  345.           add      ax,2
  346.           mov      cl,30
  347.           div      cl
  348.           xor      ah,ah
  349.           push     ax
  350.           mov      cx,ax
  351.           cmp      cx,0
  352.           je       buf_s
  353.   nxt_bl: mov      es,p_lin             ;P_lin = Last Cluster of This Line
  354.           mov      ax,es:[30]
  355.           mov      p_lin,ax
  356.           loop     nxt_bl
  357.  
  358.   buf_s:  xor      ax,ax
  359.           mov      al,line_buf          ;No. Chars in Line Buffer
  360.           add      ax,2
  361.           mov      cl,30
  362.           div      cl
  363.  
  364.           pop      cx                   ;Compare Linked-List and Line_buf
  365.           xor      ah,ah
  366.           push     ax
  367.           cmp      al,cl
  368.           jae      can_n
  369.           sub      cl,al
  370.           FREE_    p_lin
  371.           mov      word ptr es:[30],0
  372.           jmp      fill_d
  373.  
  374.   can_n:  sub      al,cl
  375.           cmp      al,0
  376.           je       fill_d
  377.  
  378.           xor      cx,cx
  379.           mov      cl,al
  380.   new_1:  NEW_
  381.           mov      es,p_lin
  382.           mov      es:[30],ax
  383.           mov      p_lin,ax
  384.           mov      es,ax
  385.           mov      word ptr es:[30],0
  386.           loop     new_1
  387.  
  388.   fill_d: cld
  389.           mov      ax,p_ptr
  390.           mov      p_lin,ax
  391.           mov      es,ax
  392.           mov      di,2
  393.           mov      si,offset line_buf
  394.           mov      cx,28                ;Part 1
  395.   rep     movsb
  396.           pop      cx
  397.           cmp      cx,0
  398.           je       g_end
  399.   r_fill: push     cx
  400.           pushf
  401.           cld
  402.           mov      di,0
  403.           mov      ax,es:[30]
  404.           mov      p_lin,ax             ;P_line:=P_line^.next
  405.           mov      es,ax
  406.           mov      cx,30
  407.   rep     movsb
  408.           popf
  409.           pop      cx
  410.           loop     r_fill
  411.  
  412.   g_end:  popf
  413.           pop      cx
  414.           pop      bx
  415.           pop      ax
  416.           pop      si
  417.           pop      di
  418.           pop      es
  419.           ret
  420. get_buff  endp
  421.  
  422. ins_line  proc     near
  423.           push     ax
  424.           push     es
  425.           mov      ax,cursor_y
  426.           cmp      ax,block_top
  427.           jb       bk_1i
  428.           cmp      ax,block_end
  429.           jb       bk_2i
  430.           jmp      bk_zi
  431.   bk_1i:  inc      block_top
  432.   bk_2i:  inc      block_end
  433.   bk_zi:  push     ax
  434.           call     find_ptr
  435.           NEW_
  436.           mov      es,r_ptr             ;R_ptr^.next:=NEW_ptr
  437.           mov      es:[0],ax
  438.           mov      es,ax
  439.           mov      ax,p_ptr             ;NEW_ptr^.next:=P_ptr
  440.           mov      es:[0],ax
  441.           mov      byte ptr es:[2],0
  442.           mov      word ptr es:[30],0
  443.           inc      total_l
  444.           call     info_win
  445.           call     refresh_
  446.           pop      es
  447.           pop      ax
  448.           ret
  449. ins_line  endp
  450.  
  451. del_line  proc     near
  452.           push     ax
  453.           push     cx
  454.           push     es
  455.           mov      ax,cursor_y
  456.           push     ax
  457.           call     find_ptr
  458.           cmp      total_l,ax
  459.           je       no_del
  460.  
  461.           mov      es,p_ptr
  462.           push     es
  463.           mov      ax,es:[0]
  464.           mov      es,r_ptr
  465.           mov      es:[0],ax
  466.           pop      es
  467.           xor      cx,cx
  468.           mov      cl,es:[2]
  469.           FREE_    p_ptr
  470.           cmp      cx,0
  471.           je       del_z
  472.  
  473.   dis_m:  mov      ax,es:[30]
  474.           mov      es,ax
  475.           FREE_    ax
  476.           loop     dis_m
  477.  
  478.   del_z:  dec      total_l
  479.           call     info_win
  480.           call     refresh_
  481.  
  482.   no_del: pop      es
  483.           pop      cx
  484.           pop      ax
  485.           ret
  486. del_line  endp
  487.  
  488. load_act  proc     near
  489.           push     es
  490.           push     di
  491.           push     si
  492.           push     bx
  493.           push     dx
  494.           CURSOR_0
  495.  
  496.   dir_fu: mov      es,monitor
  497.           mov      di,y_table[4]
  498.           add      di,96
  499.           mov      si,offset load_fun+1
  500.           mov      al,1eh
  501.           mov      cx,3
  502.           xor      bx,bx
  503.           mov      bl,load_fun[0]
  504.   dw_ld1: push     cx
  505.           pushf
  506.           mov      cx,bx
  507.   f_ld1:  movsb
  508.           stosb
  509.           loop     f_ld1
  510.           add      di,160
  511.           sub      di,bx
  512.           sub      di,bx
  513.           popf
  514.           pop      cx
  515.           loop     dw_ld1
  516.           mov      cx,16
  517.   dw_ld2: push     cx
  518.           pushf
  519.           mov      cx,bx
  520.   f_ld2:  movsb
  521.           stosb
  522.           loop     f_ld2
  523.           add      di,160
  524.           sub      di,bx
  525.           sub      di,bx
  526.           sub      si,bx
  527.           popf
  528.           pop      cx
  529.           loop     dw_ld2
  530.  
  531.           add      si,bx
  532.           mov      cx,bx
  533.   z_ld:   movsb
  534.           stosb
  535.           loop     z_ld
  536.  
  537.           mov      byte ptr es:[580],'*'       ;*
  538.           mov      byte ptr es:[582],'.'       ;.
  539.           mov      byte ptr es:[584],'*'       ;*
  540.                                         ;UPPER Draw Load Table
  541.           mov      total_f,0
  542.           mov      total_d,0
  543.           mov      file_y,1
  544.           mov      local_y,1
  545.           mov      file_top,0
  546.           mov      file_ptr,0
  547.  
  548.           mov      dx,offset dir_
  549.           mov      cx,07h               ;All Kind Of File
  550.           mov      ah,4eh
  551.           int      21h
  552.           jnc      ff_1st
  553.           jmp      d_dir
  554.   ff_1st: NEW_
  555.           inc      total_f
  556.           mov      file_top,ax
  557.           mov      file_ptr,ax
  558.           mov      es,ax
  559.           mov      di,2
  560.           mov      si,9eh               ;DTA (DS:009E) Put Filename Table
  561.           mov      cx,13
  562.           push     ds
  563.           mov      ds,psp_start
  564.           cld
  565.   rep     movsb
  566.           pop      ds
  567.  
  568.   r_r_f:  mov      ah,4fh
  569.           int      21h
  570.           jc       f_f1
  571.           NEW_
  572.           inc      total_f
  573.           mov      es:[0],ax
  574.           mov      es,ax
  575.           mov      file_ptr,ax
  576.           mov      di,2
  577.           mov      si,9eh               ;DTA (DS:009E) Put Filename Table
  578.           mov      cx,13
  579.           push     ds
  580.           mov      ds,psp_start
  581.           cld
  582.   rep     movsb
  583.           pop      ds
  584.           jmp      r_r_f
  585.   f_f1:   mov      word ptr es:[0],0
  586.  
  587.   d_dir:  mov      dx,offset dir_       ;<<<<<<<< This Area Find SubDir
  588.           mov      cx,1fh               ;Directory
  589.           mov      ah,4eh
  590.           int      21h
  591.           jnc      dd_1st
  592.           jmp      ff_dd0
  593.   dd_1st: push     es
  594.           mov      es,psp_start
  595.           mov      al,es:[95h]
  596.           pop      es
  597.           and      al,10h
  598.           cmp      al,10h
  599.           jne      r_r_d
  600.           NEW_
  601.           inc      total_d
  602.           mov      bx,es
  603.           cmp      bx,file_ptr
  604.           je       ff_ex
  605.           mov      file_top,ax
  606.           jmp      dd_ex
  607.   ff_ex:  mov      es:[0],ax
  608.   dd_ex:  mov      es,ax
  609.           mov      byte ptr es:[2],16
  610.           mov      di,3
  611.           mov      si,9eh               ;DTA (DS:009E) Put Directory Table
  612.           mov      cx,13
  613.           push     ds
  614.           mov      ds,psp_start
  615.           cld
  616.   rep     movsb
  617.           pop      ds
  618.  
  619.   r_r_d:  mov      ah,4fh
  620.           int      21h
  621.           jc       d_d1
  622.           push     es
  623.           mov      es,psp_start
  624.           mov      al,es:[95h]
  625.           pop      es
  626.           and      al,10h
  627.           cmp      al,10h
  628.           jne      r_r_d
  629.           NEW_
  630.           inc      total_d
  631.           mov      es:[0],ax
  632.           mov      es,ax
  633.           mov      byte ptr es:[2],16
  634.           mov      di,3
  635.           mov      si,9eh               ;DTA (DS:009E) Put Directory Table
  636.           mov      cx,13
  637.           push     ds
  638.           mov      ds,psp_start
  639.           cld
  640.   rep     movsb
  641.           pop      ds
  642.           jmp      r_r_d
  643.   d_d1:   mov      word ptr es:[0],0    ; This Area Find SubDir >>>>>>>>
  644.  
  645.   ff_dd0: mov      dx,total_f           ;DX register put TOTAL file/dir
  646.           add      dx,total_d
  647.           cmp      dx,0
  648.           je       ff_dd
  649.  
  650.           mov      cx,dx
  651.           mov      es,file_top
  652.   _nn_:   push     cx
  653.           mov      cx,20
  654.           mov      eol_flag,0  ;Borrow Eol_flag....
  655.           mov      di,2
  656.   _ll_:   cmp      eol_flag,1
  657.           jne      fnd_00
  658.           mov      byte ptr es:[di],0
  659.   fnd_00: cmp      byte ptr es:[di],0
  660.           jne      r_scan
  661.           mov      eol_flag,1
  662.   r_scan: inc      di
  663.           loop     _ll_
  664.           pop      cx
  665.           mov      es,es:[0]
  666.           loop     _nn_
  667.  
  668.   ff_dd:  cmp      dx,0
  669.           je       rr_kk
  670.           call     show_dir
  671.   rr_kk:  mov      ah,0
  672.           int      16h
  673.           cmp      ah,72    ;<UP>
  674.           jne      kk_1
  675.           cmp      dx,0
  676.           je       rr_kk
  677.           cmp      file_y,1
  678.           je       rr_kk
  679.           dec      file_y
  680.           cmp      local_y,1
  681.           je       ff_dd
  682.           dec      local_y
  683.           jmp      ff_dd
  684.  
  685.   kk_1:   cmp      ah,80    ;<Down>
  686.           jne      kk_2
  687.           cmp      dx,0
  688.           je       rr_kk
  689.           cmp      file_y,dx
  690.           je       rr_kk
  691.           inc      file_y
  692.           cmp      local_y,16
  693.           je       ff_dd
  694.           inc      local_y
  695.           jmp      ff_dd
  696.  
  697.   kk_2:   cmp      ah,28    ;<Enter>
  698.           jne      kk_3
  699.           cmp      dx,0
  700.           jne      ex_01f
  701.           jmp      ex_0f
  702.   ex_01f: mov      ax,total_f
  703.           cmp      file_y,ax
  704.           jbe      open_f
  705.           push     ds
  706.           mov      ds,file_ptr
  707.           mov      dx,3
  708.           mov      ah,3bh
  709.           int      21h
  710.           pop      ds
  711.           call     free_dir
  712.           jmp      dir_fu
  713.  
  714.   open_f: call     loading
  715.           jmp      ex_ld
  716.  
  717.   kk_3:   cmp      ah,1     ;<ESC>
  718.           jne      kk_4
  719.           cmp      dx,0
  720.           je       ex_00f
  721.           jmp      ex_ld
  722.   ex_00f: jmp      ex_0f
  723.  
  724.   kk_4:   cmp      ah,73    ;<Page Up>
  725.           jne      kk_5
  726.           mov      ax,file_y    ;File No.
  727.           mov      cx,local_y
  728.           sub      ax,cx
  729.           cmp      ax,15
  730.           ja       sub_15
  731.           cmp      file_y,15
  732.           ja       su__15
  733.           mov      local_y,1
  734.           mov      file_y,1
  735.           jmp      p_up
  736.  
  737.   su__15: add      cx,ax
  738.           sub      cx,15
  739.           mov      local_y,cx
  740.   sub_15: sub      file_y,15
  741.   p_up:   jmp      ff_dd
  742.  
  743.   kk_5:   cmp      ah,81    ;<Page Down>
  744.           jne      kk_6
  745.           cmp      dx,16
  746.           ja       m_16_f
  747.           mov      local_y,dx
  748.           mov      file_y,dx
  749.           jmp      ff_dd
  750.   m_16_f: mov      bx,dx    ;BX = Total Files
  751.           mov      cx,local_y
  752.           neg      cx
  753.           add      cx,17       ;Backward
  754.           mov      ax,file_y   ;AX = File No.
  755.           sub      bx,ax
  756.           inc      bx          ;BX = Backward File No.
  757.           mov      ax,bx
  758.           sub      ax,cx
  759.           cmp      ax,15
  760.           ja       add_15
  761.           cmp      bx,15
  762.           ja       ad__15
  763.           mov      local_y,16
  764.           mov      file_y,dx
  765.           jmp      p_dn
  766.  
  767.   ad__15: add      cx,ax
  768.           neg      cx
  769.           add      cx,32
  770.           mov      local_y,cx
  771.   add_15: add      file_y,15
  772.   p_dn:   jmp      ff_dd
  773.  
  774.   kk_6:   jmp      rr_kk
  775.  
  776.   ex_ld:  call     free_dir
  777.  
  778.   ex_0f:  CURSOR_1
  779.           pop      dx
  780.           pop      bx
  781.           pop      si
  782.           pop      di
  783.           pop      es
  784.           ret
  785. load_act  endp
  786.  
  787. show_dir  proc     near
  788.           mov      cx,file_y
  789.           sub      cx,local_y
  790.           mov      es,file_top
  791.           cmp      cx,0
  792.           je       _ptr_f
  793.   f_ptr_: mov      es,es:[0]
  794.           loop     f_ptr_
  795.  
  796.   _ptr_f: mov      p_lin,es
  797.           mov      cx,local_y
  798.           dec      cx
  799.           cmp      cx,0
  800.           je       this_
  801.   now__:  mov      es,es:[0]
  802.           loop     now__
  803.  
  804.   this_:  mov      file_ptr,es
  805.  
  806.           mov      cx,dx                ;DX register record TOTAL file/dir
  807.           cmp      cx,16
  808.           jbe      t_file
  809.           mov      cx,16
  810.   t_file:
  811.           mov      es,monitor
  812.           mov      di,y_table[10]
  813.           add      di,108
  814.   sh_f_n: mov      si,2
  815.           mov      byte ptr es:[di-2],20h
  816.           mov      byte ptr es:[di-1],1eh
  817.           mov      al,1eh
  818.           push     cx
  819.           mov      cx,19
  820.           push     ds
  821.           mov      ds,p_lin
  822.           mov      bx,ds:[0]
  823.   fff:    movsb
  824.           stosb
  825.           loop     fff
  826.           pop      ds
  827.           mov      p_lin,bx
  828.           add      di,122
  829.           cmp      bx,0
  830.           pop      cx
  831.           loop     sh_f_n
  832.  
  833.           cmp      local_y,0
  834.           je       _0_f_d
  835.           mov      bx,local_y
  836.           shl      bx,1
  837.           add      bx,8
  838.           mov      di,y_table[bx]
  839.           add      di,107
  840.           mov      cx,20
  841.   re_fd:  mov      byte ptr es:[di],70h
  842.           add      di,2
  843.           loop     re_fd
  844.   _0_f_d: ret
  845. show_dir  endp
  846.  
  847. free_dir  proc     near
  848.           mov      es,file_top
  849.   r_free: mov      bx,es:[0]
  850.           FREE_    es
  851.           mov      es,bx
  852.           cmp      bx,0
  853.           jne      r_free
  854.           ret
  855. free_dir  endp
  856.  
  857. loading   proc     near
  858.           push     ds
  859.           mov      ds,file_ptr
  860.           mov      dx,2
  861.           mov      al,00000000b         ;Read Only Mode
  862.           mov      ah,3dh               ;File_Name be Opened
  863.           int      21h
  864.           pop      ds
  865.           jnc      con_r
  866.           call     error_msg
  867.           jmp      no_rd
  868.   con_r:  mov      handle_,ax
  869.           call     new_act
  870.           mov      di,offset line_buf+1
  871.           mov      line_buf,0
  872.           mov      total_l,1
  873.           mov      eol_flag,0
  874.  
  875.   r_read: mov      bx,handle_
  876.           mov      dx,offset buffer_
  877.           mov      cx,buf_max
  878.           mov      ah,3fh
  879.           int      21h
  880.                                         ;Should Check ERROR ???
  881.           mov      cx,ax
  882.           cmp      ax,0
  883.           jne      read_1
  884.           jmp      read_z
  885.   read_1: mov      si,offset buffer_
  886.   loopr2: cld
  887.           mov      ax,seg line_buf
  888.           mov      es,ax
  889.   loopr1: cmp      byte ptr [si],1ah    ;End Of File
  890.           jne      eol_1
  891.           dec      cx
  892.           jmp      nx_lr1
  893.   eol_1:  cmp      byte ptr [si],0dh    ;End of Line (Part I)
  894.           jne      eol_2
  895.           mov      eol_flag,1
  896.           inc      si
  897.           jmp      eol_4
  898.  
  899.   eol_2:  cmp      byte ptr [si],0ah    ;End of Line (Part II)
  900.           jne      eol_3
  901.           cmp      eol_flag,1
  902.           jne      eol_3
  903.           jmp      nx_lr1
  904.  
  905.   eol_3:  cmp      line_buf,255
  906.           je       nx_lr1
  907.           inc      line_buf
  908.           movsb
  909.           mov      eol_flag,0
  910.   eol_4:  loop     loopr1
  911.  
  912.   nx_lr1: call     get_buff             ;Linked-List = Line_Buf
  913.           cmp      cx,0
  914.           je       read_3
  915.           mov      es,p_ptr
  916.           mov      bx,es:[0]            ;P_ptr^.next = BX
  917.           NEW_
  918.           mov      es:[0],ax            ;P_ptr^.next = NEW_ptr
  919.           mov      p_ptr,ax             ;P_ptr = NEW_ptr
  920.           mov      es,ax
  921.           mov      es:[0],bx            ;NEW_ptr^.next = BX
  922.           mov      byte ptr es:[2],0
  923.           mov      word ptr es:[30],0
  924.           inc      total_l
  925.           mov      di,offset line_buf+1
  926.           mov      line_buf,0
  927.           dec      cx
  928.           inc      si
  929.   no_n_l: cmp      cx,0
  930.           je       read_3
  931.           jmp      loopr2
  932.   read_3: jmp      r_read
  933.  
  934.   read_z: mov      bx,handle_
  935.           mov      ah,3eh               ;File_Name be Closed
  936.           int      21h
  937.  
  938.           mov      cx,13
  939.           mov      si,2
  940.           mov      di,offset file_name
  941.           mov      ax,seg file_name
  942.           mov      es,ax
  943.           push     ds
  944.           mov      ds,file_ptr
  945.   rep     movsb
  946.           pop  ds
  947.           call     here_dir
  948.   no_rd:  ret
  949. loading   endp
  950.  
  951. newing    proc     near
  952.           mov      ax,1
  953.           push     ax
  954.           call     find_ptr
  955.           mov      es,p_ptr
  956.   lin_1_: mov      ax,es:[30]
  957.           cmp      ax,0
  958.           je       free_a
  959.           mov      es,ax
  960.           FREE_    ax
  961.           jmp      lin_1_
  962.  
  963.   free_a: mov      cx,total_l
  964.           dec      cx
  965.           cmp      cx,0
  966.           jne      free_b
  967.           jmp      new_z_
  968.  
  969.   free_b: mov      es,p_ptr             ;P_ptr = P_ptr^.next
  970.           mov      ax,es:[0]            ;^^^^^ 1st = 2nd
  971.           mov      p_ptr,ax
  972.           mov      es,p_ptr
  973.  
  974.   free_c: mov      ax,es:[30]
  975.           cmp      ax,0
  976.           je       free_d
  977.           mov      es,ax
  978.           FREE_    ax
  979.           jmp      free_c
  980.  
  981.   free_d: mov      es,p_ptr             ;P_ptr = P_ptr^.next
  982.           mov      ax,es:[0]
  983.           mov      p_ptr,ax
  984.           FREE_    es
  985.           mov      es,p_ptr
  986.           loop     free_c
  987.  
  988.   new_z_: mov      es,r_ptr
  989.           mov      es,es:[0]
  990.           mov      p_ptr,es
  991.           mov      byte ptr es:[2],0
  992.           mov      word ptr es:[30],0
  993.           mov      ax,seg top_
  994.           add      ax,2
  995.           mov      es:[0],ax
  996.           ret
  997. newing    endp
  998.  
  999. save_act  proc     near                 ;Stack Put File name address
  1000.           push     bp
  1001.           mov      bp,sp
  1002.           mov      dx,[bp+4]
  1003.  
  1004.           mov      cx,00
  1005.           mov      ah,3ch
  1006.           int      21h
  1007.           jnc      save_y
  1008.           call     error_msg
  1009.           mov      cl,0                 ;Fail
  1010.           jmp      out_sa
  1011.   save_y: mov      handle_,ax
  1012.           mov      ax,seg top_
  1013.           mov      es,ax
  1014.           mov      cx,total_l
  1015.  
  1016.   save_r: push     cx
  1017.           mov      ax,es:[0]
  1018.           mov      p_ptr,ax
  1019.           call     put_buff
  1020.           mov      es,ax
  1021.           mov      dx,offset line_buf+1
  1022.           xor      bx,bx
  1023.           mov      bl,line_buf
  1024.           cmp      cx,1
  1025.           jne      not_z
  1026.           mov      cx,0
  1027.           jmp      last_l
  1028.   not_z:  mov      line_buf[bx+1],0dh
  1029.           mov      line_buf[bx+2],0ah
  1030.           mov      cx,2
  1031.   last_l: add      cx,bx
  1032.           mov      bx,handle_
  1033.           mov      ah,40h
  1034.           int      21h
  1035.           pop      cx
  1036.           jnc      save_l
  1037.           call     error_msg
  1038.           jmp      save_z
  1039.  
  1040.   save_l: loop     save_r
  1041.  
  1042.   save_z: mov      bx,handle_
  1043.           mov      ah,3eh               ;File_Name be Closed
  1044.           int      21h
  1045.           mov      cl,1
  1046.  
  1047.   out_sa: pop      bp
  1048.           ret      2
  1049. save_act  endp
  1050.  
  1051. write_act proc     near
  1052.           mov      es,monitor
  1053.           mov      bx,5
  1054.           shl      bx,1
  1055.           mov      si,offset write_fun+1
  1056.           mov      al,0ah
  1057.           mov      cx,3
  1058.   wrt_f1: push     cx
  1059.           mov      di,y_table[bx]
  1060.           add      di,10
  1061.           add      bx,2
  1062.           mov      cl,write_fun[0]
  1063.   wrt_f2: movsb
  1064.           stosb
  1065.           loop     wrt_f2
  1066.           pop      cx
  1067.           loop     wrt_f1
  1068.           mov      dl,8                 ;X-axis
  1069.           mov      dh,7                 ;Y-axis
  1070.           mov      ax,offset wrt_file
  1071.           push     ax
  1072.           call     read_line
  1073.           cmp      cl,0
  1074.           je       no_w
  1075.           inc      ax
  1076.           push     ax
  1077.           call     save_act
  1078.           cmp      cl,0
  1079.           je       no_w
  1080.           mov      cl,wrt_file[0]
  1081.           xor      ch,ch
  1082.           add      cx,2
  1083.           mov      ax,ds
  1084.           mov      es,ax
  1085.           mov      si,offset wrt_file
  1086.           mov      di,offset this_dir
  1087.   rep     movsb
  1088.           call     show_name
  1089.   no_w:   ret
  1090. write_act endp
  1091.  
  1092. print_act proc     near                 ;Stack Put Start Line
  1093.           push     bp                   ;Stack Put Print Line's Numbers
  1094.           push     dx
  1095.           mov      bp,sp
  1096.           mov      dx,0
  1097.           mov      ah,2
  1098.           int      17h
  1099.           and      ah,08h
  1100.           cmp      ah,08h
  1101.           jne      prn_on
  1102.           call     error_msg
  1103.           jmp      out_pn
  1104.  
  1105.   prn_on: mov      ax,[bp+8]
  1106.           push     ax
  1107.           call     find_ptr
  1108.           mov      cx,[bp+6]
  1109.  
  1110.   prn_r:  push     cx
  1111.           call     put_buff
  1112.           mov      es,p_ptr
  1113.           mov      ax,es:[0]
  1114.           mov      p_ptr,ax
  1115.           mov      dx,offset line_buf+1
  1116.           xor      bx,bx
  1117.           mov      bl,line_buf
  1118.           mov      line_buf[bx+1],0dh
  1119.           mov      line_buf[bx+2],0ah
  1120.           mov      cx,2
  1121.           add      cx,bx
  1122.           mov      bx,4h
  1123.           mov      ah,40h
  1124.           int      21h
  1125.           pop      cx
  1126.           jnc      prn_l
  1127.           call     error_msg
  1128.           jmp      out_pn
  1129.  
  1130.   prn_l:  loop      prn_r
  1131.  
  1132.   out_pn: pop       dx
  1133.           pop       bp
  1134.           ret       4
  1135. print_act endp
  1136.  
  1137. error_msg proc     near
  1138.           push     cx
  1139.           CURSOR_0
  1140.           mov      es,monitor
  1141.           mov      di,1600
  1142.           mov      si,offset msg_
  1143.           mov      cx,80
  1144.           mov      al,0ch
  1145.   m_g_:   movsb
  1146.           stosb
  1147.           loop     m_g_
  1148.           mov      ah,0
  1149.           int      16h
  1150.           CURSOR_1
  1151.           pop      cx
  1152.           ret
  1153. error_msg endp
  1154.  
  1155. help_win  proc     near
  1156.           push     cx
  1157.           mov      es,monitor
  1158.           mov      bx,4
  1159.           shl      bx,1
  1160.           mov      si,offset win_help+2
  1161.           xor      ch,ch
  1162.           mov      cl,win_help[1]
  1163.   h_g1:   push     cx
  1164.           mov      di,y_table[bx]
  1165.           add      di,20
  1166.           add      bx,2
  1167.           mov      cl,win_help[0]
  1168.           mov      al,2eh
  1169.   h_g2:   movsb
  1170.           stosb
  1171.           loop     h_g2
  1172.           pop      cx
  1173.           loop     h_g1
  1174.  
  1175.           mov      ah,0
  1176.           int      16h
  1177.           pop      cx
  1178.           ret
  1179. help_win  endp
  1180.  
  1181. chg_drive proc     near
  1182.           mov      ah,19h
  1183.           int      21h
  1184.           add      al,65
  1185.           mov      drive_fun[64],al
  1186.           mov      es,monitor
  1187.           mov      si,offset drive_fun+1
  1188.           mov      bx,4
  1189.           shl      bx,1
  1190.           mov      cx,3
  1191.   l_drv:  push     cx
  1192.           mov      di,y_table[bx]
  1193.           add      di,46
  1194.           mov      cl,drive_fun
  1195.           mov      al,0bh
  1196.   drv_f:  movsb
  1197.           stosb
  1198.           loop     drv_f
  1199.           add      bx,2
  1200.           pop      cx
  1201.           loop     l_drv
  1202.  
  1203.           mov      dl,56
  1204.           mov      dh,5
  1205.           mov      bx,0
  1206.           mov      ah,2
  1207.           int      10h
  1208.  
  1209.   re_drv: mov      ah,0
  1210.           int      16h
  1211.           cmp      al,27
  1212.           je       drv_z
  1213.           cmp      al,90
  1214.           jbe      try_d
  1215.           sub      al,32
  1216.   try_d:  sub      al,65
  1217.           mov      dl,al
  1218.           mov      ah,0eh
  1219.           int      21h
  1220.           jc       re_drv
  1221.   drv_z:  ret
  1222. chg_drive endp
  1223.  
  1224. code      ends
  1225.           end
  1226.